/**
 * Created by ZFL on 2017/10/18.
 */
var vm=new Vue({
    el:'#myRecruit',
    data:{
        normalUsers:[],    //招募的普通用户信息
        shopKeepers:[],  //招募的店主信息
        userImage:'',
        myInfo:[],
        id:0,
        storeName:'',
        normalUserNum:0,    //普通用户人数
        storeUserNum:0      //店主人数
    },
    methods:{

    }
})


function appInit(){
    PageInit();
}
Vue.filter('price',function(value){
    return divideNumber(value,100);
})


function PageInit() {
    vm.rank = $.getPara('rank');
    getUserInfo();
    getStorers();
    userCount()

}

var pageNum = 1;
var pageSize =30;
var userId=$.getPara('userId');
//得到用户的信息
function getUserInfo(){
    $.ajaxHandler({
        model:function(){
            var obj={};
            obj.userId=userId;
            return obj;
        },
        visibleTime: 0,
        dataType: "json",
        visible:'hide',
        api:'yg_baijiaapp/user/getUserEntityByIdNoPassword',
        success:function(res){
            if(res.code==10000){
                var data=res.data;
                vm.userImage=data.picture;
                vm.storeName=data.nickName;
            }
        }

    })
}
//得到招募店主和普通用户的人数
function userCount(){
    $.ajaxHandler({
        model:function(){
            var obj={};
            obj.userId=userId;
            return obj;
        },
        visibleTime: 0,
        dataType: "json",
        visible:'hide',
        api:'/yg_baijiaapp/statistics/myRecruitingCount',
        success:function(res){
            if(res.code==10000){
                var data=res.data;
                vm.normalUserNum=data.normalUserNum;
                vm.storeUserNum=data.storeUserNum;
            }else{
                YDUI.dialog.toast(res.message,'error',1000)
            }
        }
    })
}
//招募店主信息
function getStorers(){
    $.ajaxHandler({
        model:function(){
            var obj={};
            obj.selectType=4;
            obj.userId=userId;
            obj.pageNum = pageNum;
            obj.pageSize = pageSize;
            return obj;
        },
        visibleTime: 0,
        dataType: "json",
        visible:'hide',
        api:'yg_baijiaapp/statistics/getSalesCommissionRank',
       success:function(res){
            if(res.code==10000){
                var data=res.data;
                vm.shopKeepers=data;

            }else{
                YDUI.dialog.toast(res.message,'error',1000)
            }
        }
    })
}




